export default function deepCopy<T>(obj: T): T {
    if (obj === null || typeof obj !== 'object') {
      return obj;
    }
   
    if (obj instanceof Date) {
      return new Date(obj.getTime()) as any;
    }
   
    if (obj instanceof Array) {
      return obj.reduce((arr, item, i) => {
        arr[i] = deepCopy(item);
        return arr;
      }, [] as T);
    }
   
    if (obj instanceof Object) {
      return Object.keys(obj).reduce((newObj, key) => {
        newObj[key] = deepCopy((obj as any)[key]);
        return newObj;
      }, {} as T);
    }
  }